'use strict';
module.exports = async ({collection, dbCmd, params, token, uniID}) => {
	let res = {}
	let payload = await uniID.checkToken(token)
	if(params){
		params = JSON.parse(params)
	}
	let pageSize = Number(params.pageSize)
	let pageNumber = Number((Number(params.pageNumber)-1) * pageSize)
	if (payload.code == 0) {
		let total = (await collection.where({platform: dbCmd.eq(1)}).count()).total
		res = await collection.where({
				platform: dbCmd.eq(1),
				username:params.username?new RegExp(`^${params.username}`, 'i'):dbCmd.exists(true)
			})
			.skip(pageNumber)
			.limit(pageSize)
			.field({
				last_login_ip:true,
				last_login_date:true,
				register_date:true,
				roles:true,
				status:true,
				username:true,
			})
			.get()
		res = {...res,total,code:0,msg:'查询成功'}
	} else {
		res = payload
	}
	//返回数据给客户端 
	return res
}
